home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / pcw.zip / INT24DMO.C < prev    next >
C/C++ Source or Header  |  1991-10-20  |  3KB  |  99 lines

  1. /**********************************************************/
  2. /* Program Id.               Int24tst.C                   */
  3. /* Author.                   Stan Milam.                  */
  4. /* Date Written.             11/08/89.                    */
  5. /*                                                        */
  6. /* Demonstrates the Critical Interrupt capabilities of PCW*/
  7. /*    1.  Access disk drive that is not ready.            */
  8. /*    2.  Write to printer that is not ready.             */
  9. /*    3.  Write to AUXillary device (not ready).          */
  10. /*    4.  Write to LPT1 device (not ready).               */
  11. /**********************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <dos.h>
  15. #ifdef __ZTC__
  16. #  include <direct.h>
  17. #else
  18. #  include <dir.h>
  19. #endif
  20. #include <pcwproto.h>
  21.  
  22. static char *blkmsg[] = {
  23.    "This program is a demonstration  of PC Window's Critical",
  24.    "Interrupt capablities.  Instead  of seeing  the  familar",
  25.    "\"Abort, Retry, Ignore\" PCW will capture the DOS Critical",
  26.    "Interrupt and use a window with a  menu to ask what  you",
  27.    "want to do. When you make a choice  the window goes away",
  28.    "leaving your screen as it was before  the error. To make",
  29.    "this demonstration work  please turn  off  your  printer",
  30.    "and open the door to drive  A:. If you have a modem turn",
  31.    "it off too.  Press any key  to start the demonstration. ",
  32.    NULL
  33. };
  34.  
  35. /**********************************************************/
  36. /*                      device_write()                    */
  37. /*                                                        */
  38. /* Open the device passed and attempt to write the string */
  39. /* "Hello World!". If the device is inactive INT 24 will  */
  40. /* be called by DOS and guess who is taking care of INT 24*/
  41. /**********************************************************/
  42.  
  43. void device_write(char *device) {
  44.  
  45.    FILE  *fp;
  46.    static char *msg = "Hello World!";
  47.  
  48.    fp = fopen(device, "w");
  49.    if (fp != NULL) {
  50.       if (fputs(msg, fp) == EOF)
  51.          printf("Error Writing to device %s\n",device);
  52.       fclose(fp);
  53.    }
  54.    else {
  55.       printf("Error opening device: %s\n", device);
  56.    }
  57. }
  58.  
  59. void main(void) {
  60.  
  61.   WNDPTR *wnd, *savewnd;
  62.   int mxr, mxc;
  63. #ifdef MSC
  64.   struct find_t file_block;
  65. #endif
  66. #ifdef (__ZTC__)
  67.   struct FIND  file_block;
  68. #endif
  69. #ifdef __TURBOC__
  70.   struct ffblk file_block;
  71. #endif
  72. #ifdef __POWERC
  73.   struct ffblk file_block;
  74. #endif
  75.  
  76.   bordercolor(RED,LIGHTGRAY);
  77.   titlecolor(BLUE,LIGHTGRAY);
  78.   wnd = wframe(6,10,18,70,BLACK,LIGHTGRAY);
  79.   wtitle(wnd,TOP,MIDDLE," Critical Interrupt Demonstration ");
  80.   w_block_write(wnd,2,99,blkmsg);
  81.   keywait(60);
  82.   wnd = wpop(wnd);
  83.   set_int24();
  84.   qputs(1,99,15,0,"    Attempting to access Drive A:   ");
  85. #if MSC || __ZTC__
  86.   _dos_findfirst("a:*.*",0,&file_block);
  87. #else
  88.   findfirst("a:*.*",&file_block,0);
  89. #endif
  90.   qputs(1,99,BLUE,0,  "      Now writing to file A:File    ");
  91.   device_write("A:FILE");
  92.   qputs(1,99,RED,0,   "      Now writing to device PRN     ");
  93.   device_write("PRN");
  94.   qputs(1,99,GREEN,0, "      Now writing to device AUX     ");
  95.   device_write("AUX");
  96.   qputs(1,99,YELLOW,0,"      Now writing to device LPT1    ");
  97.   device_write("LPT1");
  98. }
  99.